package com.shi.my_stream;

import java.util.ArrayList;
import java.util.List;

public class Demo02 {
    public static void main(String[] args) {
        //- 创建一个集合，存储多个字符串元素
        //- 把集合中所有以"张"开头的元素存储到一个新的集合
        //- 把"张"开头的集合中的长度为3的元素存储到一个新的集合
        //- 遍历上一步得到的集合

        //"张三丰","张无忌","张翠山","王二麻子","张良","谢广坤"

        ArrayList<String> list = new ArrayList<String> (List.of("张三丰","张无忌","张翠山","王二麻子","张良","谢广坤"));

        list.stream().filter(s -> s.startsWith("张"))
                .filter(s -> s.length() >= 3)
                .forEach(System.out::println);
    }
}
